package com.SuanFa.lanqiao;

import java.util.*;

public class a11 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[]a = new int[n];
        while (scan.hasNext()) {
            String s = scan.next();
            if (s.equals("add")) {
                int x = scan.nextInt();
                a[0]++;
            } else if (s.equals("sync")) {
                int x = scan.nextInt();
                a[x] = Math.min(a[0], a[x] + 1);
            } else {
                int min = a[0];
                for (int i = 0; i < n; i++) {
                    min = Math.min(min, a[i]);
                }
                System.out.println(min);
            }
        }
        scan.close();
    }

}
